﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Mime;
using System.Text;
using System.Windows.Forms;

namespace SO_DataFetcher.PubFunctions
{
    public class PubCommon
    {
        public static string MainPath = Application.StartupPath;
        public static string XmlDataLinksPath = MainPath + @"\Config\DataLinks.xml";
        public static string XmlSciptsPath = MainPath + @"\Config\SQLScripts.xml";
        public static string XmlActionsPath = MainPath + @"\Config\Actions.xml";
        public static string XmlParamentsPath = MainPath + @"\Config\Paraments.xml";

        public static string GetFileText(string fileName)
        {
            string txtContent = string.Empty;
            if (File.Exists(fileName))
            {
                // 遍历文件内容
                using (StreamReader reader = new StreamReader(fileName, System.Text.Encoding.GetEncoding("gbk")))
                {
                    txtContent = reader.ReadToEnd();
                }
            }

            return txtContent;
        }

        /// <summary>
        /// 设定Index
        /// </summary>
        /// <returns></returns>
        public static string SetIndex() 
        {
            string index = string.Empty;

            DateTime dateTime = DateTime.Now;

            index = dateTime.Year.ToString() + dateTime.Month.ToString() + dateTime.Day.ToString() +
                    dateTime.Hour.ToString() + dateTime.Minute.ToString() + dateTime.Second.ToString();

            return index;
        }
    }
}
